//
//  KABMallHeaderCRView.m
//  kabu
//
//  Created by XiangDongMBP on 2017/2/17.
//  Copyright © 2017年 East. All rights reserved.
//

#import "KABMallHeaderCRView.h"
#import "GGBannerView.h"
#import "KABModel.h"
#import <YYWebImage.h>

@interface KABMallHeaderCRView() <GGBannerViewDelegate>

@end

@implementation KABMallHeaderCRView

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.bannerView.delegate = self;
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(navBgViewTapped:)];
    [self.navBgView addGestureRecognizer:tapGesture];
}

#pragma mark - GGBannerViewDelegate
- (void)imageView:(UIImageView *)imageView loadImageForUrl:(NSString *)url {
    [imageView yy_setImageWithURL:[NSURL URLWithString:url] placeholder:[KABDefaultVarModel sharedInstance].bigDefaultImg options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
}

- (void)bannerView:(GGBannerView *)bannerView didSelectAtIndex:(NSUInteger)index {
    if ([self.delegate respondsToSelector:@selector(kABMallHeaderCRView:didSelectAtIndex:)]) {
        [self.delegate kABMallHeaderCRView:self didSelectAtIndex:index];
    }
}

- (void)navBgViewTapped:(UIGestureRecognizer *)gesture {
    if ([self.delegate respondsToSelector:@selector(kABMallHeaderCRView:navViewTapped:)]) {
        [self.delegate kABMallHeaderCRView:self navViewTapped:gesture.view];
    }
}


- (void)configViewWithItem:(KABMallBannerList *)banner {
    NSLog(@"配置的Banner = %@", banner.bannerImgUrlArray);
    [self.bannerView configBanner:banner.bannerImgUrlArray];
}

- (void)bannerViewStartScroll {
    self.bannerView.interval = 3;
}

- (void)bannerViewStopScroll {
    self.bannerView.interval = 0;
}

@end
